﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="sale_order.aspx.cs" Inherits="MxWeiXinPF.Web.admin.order.sale_order"
    ValidateRequest="false" %>

<%@ Import Namespace="MxWeiXinPF.Common" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>新增订单</title>
    <script type="text/javascript" src="../../scripts/jquery/jquery-1.10.2.min.js"></script>
    <script type="text/javascript" src="../../scripts/jquery/Validform_v5.3.2_min.js"></script>
    <script type="text/javascript" src="../../scripts/lhgdialog/lhgdialog.js?skin=idialog"></script>
    <script type="text/javascript" src="../../scripts/datepicker/WdatePicker.js"></script>
    <script type="text/javascript" src="../../scripts/swfupload/swfupload.js"></script>
    <script type="text/javascript" src="../../scripts/swfupload/swfupload.queue.js"></script>
    <script type="text/javascript" src="../../scripts/swfupload/swfupload.handlers.js"></script>
    <script type="text/javascript" src="../js/layout.js"></script>
    <link href="../skin/default/style.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        $(function () {
            //初始化表单验证
            $("#form1").initValidform();
            //初始化上传控件
            $(".upload-img").each(function () {
                $(this).InitSWFUpload({ sendurl: "../../tools/upload_ajax.ashx", flashurl: "../../scripts/swfupload/swfupload.swf" });
            });
        });

        function CheckUser() {
            if ($("#<%=huserid.ClientID%>").val() != "") {
                return true;
            }
            else {
                alert("添加商品前，请先选择客户！");
                return false;
            }
        }
        function CheckUserName() {
            if ($("#<%=tbUserName.ClientID%>").val() != "") {
                return true;
            }
            else {
                alert("用户过多，请输入关键字查询，可以输入客户名称或电话，支持模糊查找！");
                return false;
            }
            return true;
        }
    </script>
</head>
<body class="mainbody">
    <form id="form1" runat="server">
    <!--导航栏-->
    <div class="location">
        <a href="javascript:history.back(-1);" class="back"><i></i><span>返回上一页</span></a>
        <a href="../center.aspx" class="home"><i></i><span>首页</span></a> <i class="arrow">
        </i><span>新增订单</span>
    </div>
    <div class="line10">
    </div>
    <!--/导航栏-->
    <!--内容-->
    <div class="content-tab-wrap">
        <div id="floatHead" class="content-tab">
            <div class="content-tab-ul-wrap">
                <ul>
                    <li><a href="javascript:;" onclick="tabs(this);" class="selected">订单资料</a></li>
                </ul>
            </div>
        </div>
    </div>
    <div class="tab-content">
        <input id="hopenid" type="hidden" runat="server" />
        <input id="huserid" type="hidden" runat="server" />
        <input id="horderid" type="hidden" runat="server" />
             <dl>
            <dt>发货方式</dt>
            <dd>
                <asp:DropDownList ID="ddlexpress" runat="server" datatype="*" errormsg="请选择发货方式"
                    sucmsg=" ">
                </asp:DropDownList>
            </dd>
        </dl>
        <dl>
            <dt>支付方式</dt>
            <dd>
                <asp:DropDownList ID="ddlpayment" runat="server" datatype="*" errormsg="请选择支付方式"
                    sucmsg=" ">
                </asp:DropDownList>
            </dd>
        </dl>
        <dl>
            <dt>添加客户</dt>
            <dd>
                <asp:TextBox ID="tbUserName" runat="server" CssClass="input normal" sucmsg=" "></asp:TextBox>
                <asp:Button ID="bnSelectUser" runat="server" Text="查找客户" CssClass="btn" OnClientClick="return CheckUserName();"
                    OnClick="bnSelectUser_Click" />
            </dd>
        </dl>
        <dl>
            <dt>添加商品</dt>
            <dd>
                <asp:TextBox ID="tbkeyword" runat="server" CssClass="input normal" sucmsg=" "></asp:TextBox>
                <asp:Button ID="btnSelectProduct" runat="server" Text="查找商品" OnClientClick="return CheckUser();"
                    CssClass="btn" OnClick="btnSelectProduct_Click" />
            </dd>
        </dl>       
        <dl>
            <dt>订单号</dt>
            <dd>
                <span id="spanOrderNo">
                <%#model == null ? "" : model.order_no %>
                </span>
            </dd>
        </dl>
        <asp:Repeater ID="Repeater1" runat="server">
            <HeaderTemplate>
                <dl>
                    <dt>商品列表</dt>
                    <dd>
                        <table border="0" cellspacing="0" cellpadding="0" class="border-table" width="98%">
                            <thead>
                                <tr>
                                   <th>
                                        货号
                                    </th>
                                    <th>
                                        商品名称
                                    </th>
                                    <th width="8%">
                                        销售价
                                    </th>
                                    <th width="8%">
                                        优惠价
                                    </th>
                                    <th width="6%">
                                        数量
                                    </th>
                                    <th width="10%">
                                        金额合计
                                    </th>
                                    <th width="8%">
                                        商品规格
                                    </th>
                                    <th width="12%">
                                        生产厂家
                                    </th>
                                </tr>
                            </thead>
                            <tbody>
            </HeaderTemplate>
            <ItemTemplate>
                <tr class="td_c">
                    <td style="text-align: left; white-space: normal;">
                        <%#Eval("sku")%>
                    </td>
                    <td style="text-align: left; white-space: normal;">
                        <%#Eval("goods_title")%>
                    </td>
                    <td>
                        <%#Eval("market_price")%>
                    </td>
                    <td>
                        <%#Eval("sale_price")%><asp:HiddenField ID="hreal_price" Value='<%#Eval("sale_price")%>' runat="server" />
                    </td>
                    <td>
                         <asp:TextBox ID="txtquantity" runat="server" Text='<%#Eval("quantity")%>' CssClass="sort" onkeydown="return checkNumber(event);" />
                        <asp:HiddenField ID="hgoodsid" Value='<%#Eval("id")%>' runat="server" />
                    </td>
                    <td>
                        <%#Convert.ToDecimal(Eval("sale_price"))*Convert.ToInt32(Eval("quantity"))%>
                    </td>
                    <td>
                        <%# Eval("spec") %>
                    </td>
                    <td>
                        <%# Eval("factory") %>
                    </td>
                </tr>
            </ItemTemplate>
            <FooterTemplate>
                </tbody> </table> </dd> </dl>
            </FooterTemplate>
        </asp:Repeater>
    </div>
    <!--/内容-->
    <!--工具栏-->
    <div class="page-footer">
        <div class="btn-list">
            <asp:Button ID="btnSubmit" runat="server" Text="提交保存" CssClass="btn" OnClick="btnSubmit_Click" />
            <input name="btnReturn" type="button" value="返回上一页" class="btn yellow" onclick="javascript: history.back(-1);" />
        </div>
        <div class="clear">
        </div>
    </div>
    <!--/工具栏-->
    <div id="DivDoctorList" runat="server" style="width: 800px; position: absolute; border: #E4E4E4 8px solid;
        top: 30%; left: 10%; display: none">
        <div id="Div1" runat="server" style="width: 800px; background-color: #4AB5DF; text-align: right;
            line-height: 30px;">
            <span style="color: #FFFFFF; font-size: 14px; float: left; padding-left: 10px;">请选择会员：
            </span>
            <asp:ImageButton ID="ImageButton1" ImageUrl="~/images/w3.jpg" runat="server" OnClick="ImageButton1_Click" />
        </div>
        <asp:DataGrid ID="dgUser" runat="server" Width="100%" AutoGenerateColumns="False"
            BackColor="#ffffff" BorderColor="#DEDFDE" BorderWidth="1px" CellPadding="4" ForeColor="#000000"
            GridLines="Vertical" Height="30px" ItemStyle-HorizontalAlign="Center" HeaderStyle-CssClass="HeaderStyle"
            HeaderStyle-HorizontalAlign="Center" OnItemCommand="dgUser_ItemCommand" BorderStyle="None"
            Font-Names="微软雅黑">
            <PagerStyle BackColor="#f3f4f4" ForeColor="#000000" HorizontalAlign="Right" Mode="NumericPages" />
            <AlternatingItemStyle BackColor="White" />
            <ItemStyle HorizontalAlign="Center" BackColor="#f3f4f4" Font-Bold="False"></ItemStyle>
            <Columns>
                <asp:BoundColumn DataField="id" ReadOnly="True" HeaderText="用户ID" Visible="false">
                </asp:BoundColumn>
                <asp:BoundColumn DataField="wxopenid" ReadOnly="True" HeaderText="openid" Visible="false">
                </asp:BoundColumn>
                <asp:BoundColumn DataField="nick_name" ReadOnly="True" HeaderText="姓名（呢称）" Visible="false">
                </asp:BoundColumn>
                <asp:TemplateColumn SortExpression="nick_name" HeaderText="姓名（呢称）" ItemStyle-Wrap="False">
                    <HeaderStyle Wrap="False" HorizontalAlign="Center"></HeaderStyle>
                    <ItemStyle Wrap="False"></ItemStyle>
                    <ItemTemplate>
                        <asp:LinkButton ID="lkbName" runat="server" ForeColor="Black" CommandName="SelectName"><%# DataBinder.Eval(Container.DataItem, "nick_name")%></asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateColumn>
                <asp:BoundColumn DataField="sex" ReadOnly="True" HeaderText="性别"></asp:BoundColumn>
                <asp:BoundColumn DataField="mobile" ReadOnly="True" HeaderText="电话"></asp:BoundColumn>
            </Columns>
            <FooterStyle BackColor="#CCCC99" />
            <SelectedItemStyle BackColor="#CE5D5A" ForeColor="White" Font-Bold="True" />
            <HeaderStyle HorizontalAlign="Center" BackColor="#DDDDDD" Font-Bold="True" ForeColor="Black">
            </HeaderStyle>
        </asp:DataGrid>
    </div>
    <div id="DivProductList" runat="server" style="width: 900px;position: absolute;
        border: #E4E4E4 8px solid; top: 10%; left: 10%; display: none">
        <div id="Div3" runat="server" style="width: 900px; background-color: #4AB5DF; text-align: right;
            line-height: 30px;">
            <span style="color: #FFFFFF; font-size: 14px; float: left; padding-left: 10px;">请选择商品：
            </span>
            <asp:ImageButton ID="ImageButton2" ImageUrl="~/images/w3.jpg" runat="server" OnClick="ImageButton2_Click" />
        </div>
        <div style="width: 900px; background-color: #FFFFFF; text-align: left; line-height: 35px;">
            <table style="width: 100%;">
                <tr>
                    <td>
                        <span style="font-size: 14px; padding-left: 10px;">商品名称：</span>
                    </td>
                    <td>
                        <asp:TextBox ID="tbProductName" runat="server" Style="height: 28px; line-height: 28px;
                            width: 100px; padding: 0px 4px; border: 1px solid #ddd;"></asp:TextBox>
                    </td>
                    <td>
                        <span style="font-size: 14px; padding-left: 10px;">商品条码：</span>
                    </td>
                    <td>
                        <asp:TextBox ID="tbsku" runat="server" Style="height: 28px; line-height: 28px; width: 100px;
                            padding: 0px 4px; border: 1px solid #ddd;"></asp:TextBox>
                    </td>
                    <td>
                        <span style="font-size: 14px; padding-left: 10px;">生产厂家：</span>
                    </td>
                    <td>
                        <asp:TextBox ID="tbfactory" runat="server" Style="height: 28px; line-height: 28px;
                            width: 100px; padding: 0px 4px; border: 1px solid #ddd;"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td>
                        <span style="font-size: 14px; padding-left: 10px;">商品类别：</span>
                    </td>
                    <td>
                        <asp:DropDownList ID="ddlCategoryId" Style="height: 28px; line-height: 28px; padding: 0px 4px;
                            border: 1px solid #ddd; margin-top: 4px; width: 110px" runat="server">
                        </asp:DropDownList>
                    </td>
                    <td>
                        <span style="font-size: 14px; padding-left: 10px;">商品编码：</span>
                    </td>
                    <td>
                        <asp:TextBox ID="tbwareid" runat="server" Style="height: 28px; line-height: 28px;
                            width: 100px; padding: 0px 4px; border: 1px solid #ddd;"></asp:TextBox>
                    </td>
                    <td colspan="2">
                        <div class="r-list">
                            <asp:LinkButton ID="lbtnSearch" runat="server" CssClass="btn" style="color:fff;" OnClick="btnSearch_Click">查询</asp:LinkButton>
                        </div>
                    </td>
                </tr>
            </table>
        <table class="tbl" style="background-color: #fffmargin-top: 10px; width: 100%;">
            <asp:Repeater ID="rptList" runat="server">
                <HeaderTemplate>
                    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="ltable">
                        <thead>
                            <tr>
                                <th width="5%">
                                    选择
                                </th>
                                <th width="13%">
                                    商品条码
                                </th>
                                <th width="8%">
                                    商品类别
                                </th>
                                <th>
                                    商品名称
                                </th>
                                <th width="8%">
                                    库存
                                </th>
                                <th width="10%">
                                    销售价
                                </th>
                                <th width="6%">
                                    商品规格
                                </th>
                                <th width="20%">
                                    生产厂家
                                </th>
                            </tr>
                        </thead>
                        <tbody class="ltbody">
                </HeaderTemplate>
                <ItemTemplate>
                    <tr class="td_c">
                        <td style=" text-align:center">
                            <asp:CheckBox ID="chkId" CssClass="checkall" runat="server" Style="vertical-align: middle;" />
                            <asp:HiddenField ID="hidId" Value='<%#Eval("id")%>' runat="server" />
                        </td>
                        <td>
                            <%# Eval("sku") %>
                        </td>
                        <td>
                            <%# Eval("title") %>
                        </td>
                        <td>
                            <%# Eval("productName") %>
                        </td>
                        <td>
                            <%# Eval("stock") %>
                        </td>
                        <td>
                            <%# Eval("salePrice") %>
                        </td>
                        <td>
                            <%# Eval("spec") %>
                        </td>
                        <td>
                            <%# Eval("factory") %>
                        </td>
                    </tr>
                </ItemTemplate>
                <FooterTemplate>
                    <%#rptList.Items.Count == 0 ? "<tr><td align=\"center\" colspan=\"10\">暂无记录</td></tr>" : ""%>
                    </tbody> </table>
                </FooterTemplate>
            </asp:Repeater>
        </table>
        </div>
        <div class="page" style="background-color: #fff;">
            <webdiyer:AspNetPager ID="AspNetPager1" CssClass="pages" CurrentPageButtonClass="cpb"
                PagingButtonSpacing="0" runat="server" AlwaysShow="True" FirstPageText="首页" LastPageText="尾页"
                NextPageText="下一页" PrevPageText="上一页" ShowCustomInfoSection="Left" ShowPageIndexBox="Never"
                CustomInfoTextAlign="Left" CustomInfoHTML="第<font style='color:#ffa501'>%CurrentPageIndex%</font>/<font style='color:#ffa501'>%PageCount%</font>页，共<font style='color:#ffa501'>%RecordCount%</font>条记录，每页显示<font style='color:#ffa501'>%PageSize%</font>条"
                LayoutType="Div">
            </webdiyer:AspNetPager>
        </div>
        <div style="text-align: right; line-height: 30px; width: 900px; background-color: #fff;">
            <asp:Button ID="btn_OK" runat="server" CssClass="btn" Style="margin-left: 10px;"
                Text="确定" OnClick="btn_OK_Click" />
            <asp:Button ID="Button2" runat="server" CssClass="btn yellow" Style="margin-left: 10px;"
                Text="关闭" OnClick="Button1_Click" />
        </div>
    </div>
    </form>
</body>
</html>
